﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PrefabLoader : MonoBehaviour
{
    public GameObject prefab;
    public Transform parent;
    GameObject obj;

    void OnEnable()
    {
        if (obj == null && prefab != null)
        {
            obj = GameObject.Instantiate(prefab);
            if (parent == null)
            {
                parent = this.transform;
            }

            obj.transform.SetParent(parent, false);
            obj.layer = parent.gameObject.layer;
        }
    }
}
